<?php

include_once 'AdminController.php';

class main extends AdminController{
	
	var $pageSize = 5;
	
	function index(){  
		 if(empty($_SESSION['LOGIN'])){
		 	//header('Location:/admin.php?c=main&a=login');
		 }
		
	}  
	
	function dolist(){
		$mModel = spClass('m_active_kiss');  
		
		// 这里获取分页数据并发送到smarty模板内
		$where = ' 1=1 ';
		$datalist = $mModel->spPager($this->spArgs('page', 10), 5)->findAll($where); 
		$pager = $mModel->spPager()->getPager();
		
		//$this->_D($datalist);
		
		$this->datalist = $datalist;
		$this->pager = $pager; 
	}
	
	function adddata(){
		
	}
	
	/**
	* 用户登陆页面
	* @return
	*/
	function login(){
		
	} 
	
	function dologin(){
		$un = empty($_POST['uname'])?'':$_POST['uname'];
		$up = empty($_POST['upass'])?'':$_POST['upass'];
		if(empty($un)){
			$this->_Ajax_return(false,'请输入账号');
		}
		if(empty($up)){
			$this->_Ajax_return(false,'请输入密码');
		}
		if($un=='admin'){
			if($up=='admin123'){
				$_SESSION['LOGIN'] =  $un ;
				$this->_Ajax_return(true,'登陆完成',$_SESSION['LOGIN']);
			}else{
				$this->_Ajax_return(false,'密码错误');
			}
		}else{
			$this->_Ajax_return(false,'账号错误');
		}
	}
	
	function welcome(){
		$UID = $_SESSION['LOGIN'];
		if(empty($UID) || strlen($UID)<1){
			echo '<script>window.top.location="/admin.php?c=main&a=login";</script>';
			exit();
		}
	}
	
	function logout(){
		$_SESSION['LOGIN'] =  null;
		header('Location:/admin.php?c=main&a=login');
	}
}